package com.atguigu.gmall.search.rpc;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.search.Goods;
import com.atguigu.gmall.search.service.SearchService;
import com.atguigu.gmall.search.vo.SearchParamVo;
import com.atguigu.gmall.search.vo.SearchRespVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName: SearchRpcController
 * @Author: WDD
 * @CreateTime: 2023-01-29  15:27
 * @Description:
 */
@RequestMapping("/api/inner/rpc/search")
@RestController
public class SearchRpcController {

    @Autowired
    SearchService searchService;

    //检索商品
    @PostMapping("/searchgoods")
    public Result<SearchRespVo> search(@RequestBody SearchParamVo searchParamVo){
        SearchRespVo respVo = searchService.search(searchParamVo);
        return Result.ok(respVo);
    }

    //上架
    @PostMapping("/up/goods")
    public Result up(@RequestBody Goods goods){
        searchService.up(goods);
        return Result.ok();
    }

    //下架
    @GetMapping("/down/goods/{skuId}")
    public Result down(@PathVariable("skuId") Long skuId){
        searchService.down(skuId);
        return Result.ok();
    }
}
